﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class FilterElemsByFamilyName : ISelectionFilter
	{
		public FilterElemsByFamilyName(List<string> lisFilterFamilyName)
		{
			this.lisFilterFamilyName = lisFilterFamilyName;
		}

		bool ISelectionFilter.AllowElement(Element elem)
		{
			FamilyInstance familyInstance = elem as FamilyInstance;
			if (familyInstance != null)
			{
				string familyName = familyInstance.Symbol.Family.Name;
				return this.lisFilterFamilyName.Find((string p) => p == familyName) != null;
			}
			return false;
		}

		bool ISelectionFilter.AllowReference(Reference reference, XYZ position)
		{
			throw new NotImplementedException();
		}

		private List<string> lisFilterFamilyName = new List<string>();
	}
}
